package com.comba.patch.tool.controller;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.comba.patch.tool.utils.AlertUtils;

import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class RootLayoutController implements Initializable {
	private static final Logger LOGGER = LoggerFactory.getLogger(RootLayoutController.class);

	public void handleAbout() {
		AlertUtils.information("关于", "补丁包制作工具v1.0\n网络系统研究部-软件二室：张进");
	}

	public void handleExit() {
		System.exit(0);
	}

	public void configFileFilter() {
		try {
			FXMLLoader loader = new FXMLLoader(this.getClass().getResource("/com/comba/patch/tool/view/PatchFileFilterConfig.fxml"));
			AnchorPane pane = loader.load();
			Scene scene = new Scene(pane);
			Stage stage = new Stage();
			stage.setResizable(false);
			stage.setScene(scene);

			PatchFileFilterConfigController controller = loader.getController();
			controller.setStage(stage);

			stage.showAndWait();
		} catch (IOException e) {
			String msg = "加载补丁文件过滤配置界面失败";
			LOGGER.error(msg, e);
			AlertUtils.error(msg);
		}
	}


	@Override
	public void initialize(URL location, ResourceBundle resources) {
		// TODO Auto-generated method stub

	}

}
